home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 (Alt) / Vol 132.iso / games / 3d_hyper / 3d_hyper.dcr / Scripts_16_IntroFrameSprites Behavior.ls < prev    next >
Encoding:
Text File  |  2011-06-09  |  3.2 KB  |  91 lines

  1. property pBeginLeaveTime, pTimeToLeave, pBeginRect, pLeaving, pBeginEntryTime, pBeginning, pReadyToBegin, pLeaveType, pLeaveTarget, pBeginType, pBeginTarget, pIntroTime, pFadeInTargetBlend, pBeginLeaveBlend
  2.  
  3. on getPropertyDescriptionList me
  4.   list = [:]
  5.   addProp(list, #pLeaveType, [#comment: "Which type of leave?", #format: #symbol, #default: #fadeOut, #range: [#fadeOut, #fadeIn, #Animate, #nothing]])
  6.   addProp(list, #pLeaveTarget, [#comment: "The Leave Target (blend % or rect)", #format: #string, #default: 0])
  7.   addProp(list, #pBeginType, [#comment: "Which type of intro?", #format: #symbol, #default: #fadeIn, #range: [#fadeIn, #fadeOut, #nothing]])
  8.   addProp(list, #pBeginTarget, [#comment: "The Begin Amount (blend %)", #format: #string, #default: 0])
  9.   addProp(list, #pIntroTime, [#comment: "The Intro Time (milliseconds)", #format: #integer, #default: 750])
  10.   return list
  11. end
  12.  
  13. on LeaveThisFrame me, timeTilLeave
  14.   if pLeaveType <> #nothing then
  15.     pBeginLeaveTime = the milliSeconds
  16.     pTimeToLeave = timeTilLeave
  17.     pBeginLeaveBlend = sprite(me.spriteNum).blend
  18.     pLeaving = 1
  19.   end if
  20. end
  21.  
  22. on beginSprite me
  23.   pBeginLeaveTime = 0
  24.   pBeginRect = sprite(me.spriteNum).rect
  25.   if pBeginType <> #nothing then
  26.     pReadyToBegin = 1
  27.     if pBeginType = #fadeIn then
  28.       pFadeInTargetBlend = sprite(me.spriteNum).blend
  29.       sprite(me.spriteNum).blend = value(pBeginTarget)
  30.     else
  31.       if pBeginType = #fadeOut then
  32.         sprite(me.spriteNum).blend = 100
  33.       end if
  34.     end if
  35.   end if
  36. end
  37.  
  38. on exitFrame me
  39.   if pReadyToBegin then
  40.     pReadyToBegin = 0
  41.     pBeginEntryTime = the milliSeconds
  42.     pBeginning = 1
  43.   end if
  44.   if pLeaving then
  45.     percent = float(the milliSeconds - pBeginLeaveTime) / pTimeToLeave
  46.     if percent > 1 then
  47.       percent = 1.0
  48.     end if
  49.     if pLeaveType = #fadeOut then
  50.       targetBlend = value(pLeaveTarget)
  51.       amountToChange = (pBeginLeaveBlend - targetBlend) * percent
  52.       sprite(me.spriteNum).blend = pBeginLeaveBlend - amountToChange
  53.     else
  54.       if pLeaveType = #fadeIn then
  55.         targetBlend = 100
  56.         amountToChange = (targetBlend - value(pLeaveTarget)) * percent
  57.         sprite(me.spriteNum).blend = pBeginTarget + amountToChange
  58.       else
  59.         if pLeaveType = #Animate then
  60.           currentRect = rect(0, 0, 0, 0)
  61.           targetRect = value(pLeaveTarget)
  62.           repeat with i = 1 to 4
  63.             nextPoint = (pBeginRect[i] * (1.0 - percent)) + (targetRect[i] * percent)
  64.             currentRect[i] = nextPoint
  65.           end repeat
  66.           sprite(me.spriteNum).rect = currentRect
  67.         end if
  68.       end if
  69.     end if
  70.   else
  71.     if pBeginning then
  72.       percent = float(the milliSeconds - pBeginEntryTime) / pIntroTime
  73.       if percent > 1 then
  74.         percent = 1.0
  75.         pBeginning = 0
  76.       end if
  77.       if pBeginType = #fadeIn then
  78.         targetBlend = pFadeInTargetBlend
  79.         amountToChange = (targetBlend - value(pBeginTarget)) * percent
  80.         sprite(me.spriteNum).blend = pBeginTarget + amountToChange
  81.       else
  82.         if pBeginType = #fadeOut then
  83.           targetBlend = value(pBeginTarget)
  84.           amountToChange = (100 - targetBlend) * percent
  85.           sprite(me.spriteNum).blend = 100 - amountToChange
  86.         end if
  87.       end if
  88.     end if
  89.   end if
  90. end
  91.